-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add security header #2341
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2341 +/- ##
===========================================
- Coverage 68.17% 49.10% -19.08%
===========================================
Files 127 41 -86
Lines 3375 3179 -196
Branches 830 0 -830
===========================================
- Hits 2301 1561 -740
- Misses 1074 1419 +345
- Partials 0 199 +199
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@starsz Please take a look, thanks. |
api/conf/conf.yaml
Outdated
@@ -60,6 +60,14 @@ conf: | |||
# such as absolute path on Windows: winfile:///C:\access.log | |||
# log example: 2020-12-09T16:38:09.039+0800 INFO filter/logging.go:46 /apisix/admin/routes/r1 {"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []} | |||
max_cpu: 0 # supports tweaking with the number of OS threads are going to be used for parallelism. Default value: 0 [will use max number of available cpu cores considering hyperthreading (if any)]. If the value is negative, is will not touch the existing parallelism profile. | |||
# security: | |||
# access_control_allow_origin: "http:httpbin.org" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# access_control_allow_origin: "http:httpbin.org" | |
# access_control_allow_origin: "http://httpbin.org" |
api/conf/conf.yaml
Outdated
@@ -60,6 +60,14 @@ conf: | |||
# such as absolute path on Windows: winfile:///C:\access.log | |||
# log example: 2020-12-09T16:38:09.039+0800 INFO filter/logging.go:46 /apisix/admin/routes/r1 {"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []} | |||
max_cpu: 0 # supports tweaking with the number of OS threads are going to be used for parallelism. Default value: 0 [will use max number of available cpu cores considering hyperthreading (if any)]. If the value is negative, is will not touch the existing parallelism profile. | |||
# security: | |||
# access_control_allow_origin: "http:httpbin.org" | |||
# access_control_allow_credentials: true # support user custom cors configration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# access_control_allow_credentials: true # support user custom cors configration | |
# access_control_allow_credentials: true # support using custom cors configration |
api/internal/filter/cors.go
Outdated
@@ -16,14 +16,36 @@ | |||
*/ | |||
package filter | |||
|
|||
import "github.com/gin-gonic/gin" | |||
import ( | |||
"github.com/apisix/manager-api/internal/conf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style.
SecurityConf = Security{ | ||
XFrameOptions: "deny", | ||
ContentSecurityPolicy: "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't have the default value of AllowCredentials
AllowOrigin
AllowMethods
AllowHeaders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need default value for AllowCredentials
、AlloOrigin
、AllowMethods
、AllowHeaders
. These configuration are left to the user to customize.
Please answer these questions before submitting a pull request, or your PR will get closed.
Why submit this pull request?
What changes will this PR take into?
Please update this section with detailed description.
Related issues
fix/ #2340
Checklist: